package com.ross.mode.proxy;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @version 1.0.0
 * @className: JdkProxy
 * @description:  代理类
 * @author: zhangjunfa
 * @date: 2023/3/31 9:58
 */
@Slf4j
public class ProxyHandler<T> implements InvocationHandler {
    private final T target;

    public ProxyHandler(T target) {
        this.target = target;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        log.info("代理前-----");
        Object result = method.invoke(target, args);
        log.info("代理后-----代理方法：{}，参数：{}", method.getName(), args);
        return result;
    }
}
